# 作者 ：longxiaonan@aliyun.com
# 开发时间： 2022/11/25 9:36

from flask import Flask
from sqlhelper2 import db

app = Flask(__name__)
db = db()

@app.route('/login')
def login():
    # result = db.fetchone('select * from user where name=%s and age=%s', "long", 12)
    result = db.fetchone('select sleep(2)')
    print(result)
    return '登陆成功'

@app.route('/index')
def index():
    result = db.fetchall('select * from user')
    print(result)
    return "首页"

@app.route('/order')
def order():
    conn, cursor = db.open()
    # 自己做操作
    db.close(conn, cursor)

if __name__ == '__main__':
    app.run()